﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Ria;
using Magalie.Domaine;
using NHibernate.Linq;
using SharpArch.Data.NHibernate;
using Magalie.Web.Classes;

namespace Magalie.Web.MagServices
{
    [EnableClientAccess()]
    public class ProjetsService : NHibernateDomainService
    {
        public IQueryable<Projet> GetProjets()
        {
            return NHibernateSession.Current.Linq<Projet>();
        }

        public IQueryable<Projet> GetProjetsOrganisation(Guid idOrganisation)
        {
            return NHibernateSession.Current.Linq<Projet>().Where(p => p.Organisation.Id == idOrganisation);
        }

        public void InsertProjet(Projet projet)
        {
            NHibernateSession.Current.Save(projet);
        }

        public void UpdateProjet(Projet projet)
        {
            NHibernateSession.Current.Update(projet);
            //this.Context.AttachAsModified(currentEmployee, this.ChangeSet.GetOriginal(currentEmployee));
        }

        public void DeleteEmployee(Projet projet)
        {
            NHibernateSession.Current.Delete(projet);

            //if ((employee.EntityState == EntityState.Detached))
            //{
            //    this.Context.Attach(employee);
            //}
            //this.Context.DeleteObject(employee);
        }
    }
}